//
//  MainTitleV.m
//  ZITHER
//
//  Created by weixin on 2018/8/27.
//  Copyright © 2018年 weixn. All rights reserved.
//

#import "MainTitleV.h"

@implementation MainTitleV

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.BtnScroll];

    }
    return self;
}



-(void)btn:(UITapGestureRecognizer*)btn{
    
    if (self.block) {
        _block(self.btnState);
        self.btnState = !self.btnState;
    }
    
    CGAffineTransform  transform;
    
    if (self.sta==YES) {
        transform = CGAffineTransformRotate(btn.view.transform,-(M_PI/4.0));
    }else{
        transform = CGAffineTransformRotate(btn.view.transform,M_PI/4.0);
    }
    
    self.sta = !self.sta;
    
    [UIView beginAnimations:@"rotate" context:nil ];
    
    [UIView setAnimationDuration:0.3];
    
    [UIView setAnimationDelegate:self];
    
    [btn.view setTransform:transform];
    
    [UIView commitAnimations];
    
}

-(void)setArrMNormal:(NSMutableArray *)arrMNormal
{
    _arrMNormal = arrMNormal;
    self.BtnScroll.arrMNormal = arrMNormal;
}

-(void)setArrMSelect:(NSMutableArray *)arrMSelect
{
    _arrMSelect = arrMSelect;
    self.BtnScroll.arrMSelect = arrMSelect;
}

-(MainTitleScrollV*)BtnScroll
{
    if (!_BtnScroll) {
        _BtnScroll = [[MainTitleScrollV alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, 40)];
        
        @weakify(self);
        [_BtnScroll setBlock:^(NSUInteger index) {
            @strongify(self);
            if (self.blcokIndex) {
                self.blcokIndex(index);
            }
        }];
    }

    return _BtnScroll;
}

-(void)changeBtn:(NSInteger)index{
    [self.BtnScroll changeBtn:index];
}

//-(void)setBackViewFrame:(NSInteger)index{
//
//
//    //    if (kUSER_INFO_MANAGER.userIsLogin) {
//
//    CGRect rect = CGRectMake(0, 0, 0, 0);
//    CGPoint point = CGPointMake(0, 0);
//    //    [_btn1 setTitleColor:[UIColor colorWithHex:@"999999"] forState:UIControlStateNormal];
//    //    [_btn2 setTitleColor:[UIColor colorWithHex:@"999999"] forState:UIControlStateNormal];
//    //    [_btn3 setTitleColor:[UIColor colorWithHex:@"999999"] forState:UIControlStateNormal];
//    //    _btn2.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
//    //    _btn2.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
//    //    _btn3.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
//
//    if (index == 0) {
//        rect = CGRectMake(0, backHeight, kScreenW/3.0, 3);
//        point =  CGPointMake(0, 0);
//        //            [_btn1 setTitleColor:[UIColor colorWithHex:@"333333"] forState:UIControlStateNormal];
//        //            _btn1.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:14];
//    }else if (index == 1){
//        rect = CGRectMake(kScreenW/3.0, backHeight, kScreenW/3.0, 3);
//        point =  CGPointMake(kScreenW,0);
//        //            [_btn2 setTitleColor:[UIColor colorWithHex:@"333333"] forState:UIControlStateNormal];
//        //            _btn2.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:14];
//    }else{
//        rect = CGRectMake(kScreenW/3.0*2, backHeight, kScreenW/3.0, 3);
//        point =  CGPointMake(kScreenW*2, 0);
//        //            [_btn3 setTitleColor:[UIColor colorWithHex:@"333333"] forState:UIControlStateNormal];   _btn3.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:14];
//    }
//
//    [UIView animateWithDuration:0.3 animations:^{
//        self.viewBlcak.frame = rect;
//        self.scroView.contentOffset = point;
//    }];
//    //    }else{
//    //        CGRect rect = CGRectMake(0, 0, 0, 0);
//    //        CGPoint point = CGPointMake(0, 0);
//    //
//    //        if (index == 0) {
//    //
//    //        }else if (index == 1){
//    //            rect = CGRectMake(0, backHeight, kScreenW/2.0, 3);
//    //            point =  CGPointMake(0,0);
//    //
//    //        }else{
//    //            rect = CGRectMake(kScreenW/2.0, backHeight, kScreenW/2.0, 3);
//    //            point =  CGPointMake(kScreenW, 0);
//    //        }
//    //        [UIView animateWithDuration:0.3 animations:^{
//    //            self.viewBlcak.frame = rect;
//    //            self.scroView.contentOffset = point;
//    //        }];
//    //    }
//}

@end
